package d7_homework.d2_homework.d2_secondquestion;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestJava {
    public static void main(String[] args) {
        //目标: HashMap的嵌套(HashMap嵌套HashMap)
        //1、创建一个HashMap集合存放Java学科与学科的学生
        //多态,一行经典的代码
        Map<String, Map<Integer, String>> javaSubject = new HashMap<>();

        //2、创建一个集合用于存储学生的学号,名字
        //基础班
        Map<Integer, String> studentsJavaBasicClass = new HashMap<>();
        Map<Integer, String> studentsJavaEmploymentClass = new HashMap<>();


        //将学生存储进行students集合中
        studentsJavaBasicClass.put(001, "陈平安");
        studentsJavaBasicClass.put(002, "宁姚");
        studentsJavaEmploymentClass.put(003, "叶凡");
        studentsJavaEmploymentClass.put(004, "姬紫月");

        //3、將不同班级的学生添加到学科,与学生集合中
        javaSubject.put("java基础班", studentsJavaBasicClass);
        javaSubject.put("java就业班", studentsJavaEmploymentClass);

        //遍历集合
        Set<String> javaClass = javaSubject.keySet();
        for (String aClass : javaClass) {
            System.out.println("班级:" + aClass + "\t" + "学生信息如下:");
            Map<Integer, String> students = javaSubject.get(aClass);
            students.forEach((k, v) -> System.out.println("学号:" + k + "\t" + "姓名:" + v));
        }


    }
}
